/********************************************************************/
/*                                                                  */
/*	       CREAM: A (JVM-like) Toy Abstract Machine             */
/*                                                                  */
/*		Copyright (c) 1998- , C.R. Ramakrishnan             */
/*                                                                  */
/*  $Id: inst.h,v 1.2 2012/04/26 18:23:58 cram Exp $ */
/*                                                                  */
/********************************************************************/

#ifndef Inst_Included
#define Inst_Included

/* push constants (immediate) to operand stack */

void ildc(int);
void fldc(float);
void null();

/* load/store local variables to/from operand stack */

void load();
void store();

/* increment local variable by constant */
void iinc(int);

/* arrays */
void newarray(int);
void aload();
void astore();

/* stack manipulation */

void nop();
void pop();
void dup();
void dup2();
void swap();
void swap1_2();

/* arithmetic */

void iadd();
void isub();
void imul();
void idiv();
void ineg();
void fadd();
void fsub();
void fmul();
void fdiv();
void fneg();

/* logical */

void and();
void or();
void not();

/* comparison */

void iequal();
void inotequal();
void igte();
void igt();
void ilte();
void ilt();
void fequal();
void fnotequal();
void fgte();
void fgt();
void flte();
void flt();

void oequal();
void onotequal();

/* Local Control Transfer */

#define jmp(LABEL) goto LABEL
#define jz(LABEL)  if (stack[--sp] == 0) goto LABEL
#define jnz(LABEL)  if (stack[--sp] != 0) goto LABEL

/* Method invocation and return */

#define call(X)    X()
#define ret()      {rm_env(); return;}

void new_env(int, int);
void rm_env();

/* Field manipulation */

void new_heap(int);

void putfield();
void getfield();
void setstatic();
void getstatic();


/* Compiler interface */
#define entry
/* Should really be "void", but leave it blank, so that the C compiler
   doesn't complain about absence of forward references;  */

/* Miscellaneous */
void foreign();
/* an escape hatch to go to C functions. Hook for future library additions */

/* Debugging */
void print_stack();
void print_current_frame();

#endif
